package com;

import io.lettuce.core.RedisClient;
import io.lettuce.core.RedisFuture;
import io.lettuce.core.RedisURI;
import io.lettuce.core.api.async.RedisAsyncCommands;
import org.junit.Test;
import redis.clients.jedis.Jedis;

import java.util.concurrent.ExecutionException;

public class Demo2 {

    @Test
    public void test1() {
//      连接redis
        Jedis jedis = new Jedis("10.9.45.184", 6379);

//        jedis.zadd("shanxi", 50, "ss");

//        jedis.hset("111", "name","zhangsan");

//        jedis.lpush("hahahah", "www");

//        jedis.lpushx("hahahah", "zhaoliu");

        System.out.println(jedis.sismember("hahaha", "000")
        );
        jedis.close();
    }


    @Test
    public void test2() throws ExecutionException, InterruptedException {
//        获取地址
        RedisURI redisURI = RedisURI.create("redis://10.9.45.184:6379");
//        建立连接
        RedisClient redisClient = RedisClient.create(redisURI);
//      异步连接上了
        RedisAsyncCommands<String, String> async = redisClient.connect().async();
//      通过key  获取到了Future值
        RedisFuture<String> user = async.get("user");
//     获取
        String s = user.get();
        System.out.println(s);

    }

}
